// 获取用户ID
async function getUserId(ip) {
    try {
        const response = await axios.get(baseUrl + 'index', {
            headers: {
                'Content-Type': 'application/json',
                'X-Forwarded-For': ip // 假设的IP地址，根据实际需求修改
            }
        });
        return response.data;
    } catch (error) {
        console.error('获取用户ID失败:', error);
        return '';
    }
}

// 加入房间
async function joinRoom(data) {
    try {
        const response = await axios.post(baseUrl + 'joinRoom', data);
        return response.data;
    } catch (error) {
        console.error('加入房间失败:', error);
        return 0;
    }
}

// 离开房间
async function leaveRoom(data) {
    try {
        await axios.post(baseUrl + 'leaveRoom', data);
    } catch (error) {
        console.error('离开房间失败:', error);
    }
}
//获取房间用户列表
async function queryRoomUser(roomId){
    try {
        const response = await axios.get(baseUrl + 'queryRoomUser?roomId='+roomId);
        return response.data;
    } catch (error) {
        return 0;
    }
}
//创建房间
async function createRoom(data){
    try {
        await axios.post(baseUrl + 'createRoom', data);
    } catch (error) {
        console.error('创建房间失败:', error);
    }
}
//查询房间
async function queryRoom(){
    try {
        const response = await axios.get(baseUrl + 'queryRoom');
        return response.data;
    } catch (error) {
        console.error('查询房间失败:', error);
    }
}
